package com.dyz.leetcode._20_dynamicProgramming._198;

public class _198_rob03 {
    // 动态规划 + 状态压缩
    public int rob4(int[] nums) {
        if (nums.length == 1) {return nums[0];}

        int prevMax = 0;
        int currMax = 0;

        for (int num : nums) {
            int tmpMax = Math.max(currMax, prevMax + num);
            prevMax = currMax;
            currMax = tmpMax;
        }

        return currMax;
    }
}
